package com.parachutes.aspsystemapi.domian;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;

import com.parachutes.aspsystemapi.domian.group.LoginGroup;
import com.parachutes.aspsystemapi.domian.group.RegisterGroup;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 用户表
 * @TableName sys_user
 */
@TableName(value ="sys_user")
@Data
public class SysUser implements Serializable {
    /**
     * 用户ID，主键，自增
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 用户名，不能为空
     */
    @NotNull(message = "用户名，不能为空",groups = {LoginGroup.class, RegisterGroup.class})
    private String username;

    /**
     * 密码，不能为空
     */
    @NotNull(message = "密码，不能为空",groups = {LoginGroup.class, RegisterGroup.class})
    private String password;

    /**
     * 昵称，默认值为NULL
     */
    private String nickName;

    /**
     * 应用ID，默认值为NULL
     */
    private String appid;

    /**
     * 应用密钥，默认值为NULL
     */
    private String appSecret;

    /**
     * 用户类型，整数类型（例如：0 = 管理员，1 = 普通用户）
     */
    @NotNull(message = "用户类型，不能为空",groups = { RegisterGroup.class})
    private Integer type;

    /**
     * 邮箱
     */
    @NotNull(message = "邮箱，不能为空",groups = {RegisterGroup.class})
    private String email;

    /**
     * 记录创建时间，默认为当前时间
     */
    private Date createdAt;

    /**
     * 创建人ID，不能为空，表示是谁创建了此记录
     */
    private Integer createdBy;

    /**
     * 记录更新时间，自动更新时间戳
     */
    private Date updatedAt;

    /**
     * 更新人ID，不能为空，表示最后一次更新的用户ID
     */
    private Integer updatedBy;

    /**
     * 逻辑删除字段（0 = 未删除，1 = 已删除）
     */
    private Integer isDeleted;

    /**
     * 平衡
     */
    private String balance;

    /**
     * withdrawal
     */
    private String withdrawal;

    /**
     * 支付宝身份
     */
    private String alipayIdentify;
    /**
     * 支付宝名称
     */
    private String alipayName;

    /**
     * 邮箱验证码
     */
    @TableField(exist = false)
    private String code;
    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SysUser other = (SysUser) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
            && (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
            && (this.getNickName() == null ? other.getNickName() == null : this.getNickName().equals(other.getNickName()))
            && (this.getAppid() == null ? other.getAppid() == null : this.getAppid().equals(other.getAppid()))
            && (this.getAppSecret() == null ? other.getAppSecret() == null : this.getAppSecret().equals(other.getAppSecret()))
            && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()))
            && (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
            && (this.getCreatedBy() == null ? other.getCreatedBy() == null : this.getCreatedBy().equals(other.getCreatedBy()))
            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()))
            && (this.getUpdatedBy() == null ? other.getUpdatedBy() == null : this.getUpdatedBy().equals(other.getUpdatedBy()))
            && (this.getIsDeleted() == null ? other.getIsDeleted() == null : this.getIsDeleted().equals(other.getIsDeleted()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
        result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
        result = prime * result + ((getNickName() == null) ? 0 : getNickName().hashCode());
        result = prime * result + ((getAppid() == null) ? 0 : getAppid().hashCode());
        result = prime * result + ((getAppSecret() == null) ? 0 : getAppSecret().hashCode());
        result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
        result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
        result = prime * result + ((getCreatedBy() == null) ? 0 : getCreatedBy().hashCode());
        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
        result = prime * result + ((getUpdatedBy() == null) ? 0 : getUpdatedBy().hashCode());
        result = prime * result + ((getIsDeleted() == null) ? 0 : getIsDeleted().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", username=").append(username);
        sb.append(", password=").append(password);
        sb.append(", nickName=").append(nickName);
        sb.append(", appid=").append(appid);
        sb.append(", appSecret=").append(appSecret);
        sb.append(", type=").append(type);
        sb.append(", phoneNumber=").append(email);
        sb.append(", createdAt=").append(createdAt);
        sb.append(", createdBy=").append(createdBy);
        sb.append(", updatedAt=").append(updatedAt);
        sb.append(", updatedBy=").append(updatedBy);
        sb.append(", isDeleted=").append(isDeleted);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}